/*
 * ProjectileEnemyCollision.java
 *
 * Created on 28. April 2007, 15:06
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package de.tor.obj.action;

import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.collision.BasicCollisionGroup;
import de.tor.loaders.Level;
import de.tor.obj.AbstractProjectile;
import de.tor.obj.TorridityGameObject;
import de.tor.obj.impl.ProjectileFactory;

/**
 *
 * @author Charon
 */
public class ProjectileEnemyCollision extends BasicCollisionGroup{
    
    Level owner;
    
    public ProjectileEnemyCollision(Level owner) {
        this.owner = owner;
    }
    
    // when projectiles (in group a) collided with enemy (in group b)
    // what to do?
    public void collided(Sprite s1, Sprite s2) {
        ((TorridityGameObject)s2).doDamage(((TorridityGameObject)s1).getCollisionDamage());
        ((TorridityGameObject)s1).doDamage(((TorridityGameObject)s2).getCollisionDamage());
        
        if(((TorridityGameObject)s2).isDestroyed()){
            owner.fireExplosionEvent(((TorridityGameObject)s2).getDestructionAnimation());
            s2.setActive(false);
        }
        
        if(((TorridityGameObject)s1).isDestroyed()){
            owner.fireExplosionEvent(((TorridityGameObject)s1).getDestructionAnimation());
            s1.setActive(false);
        }
        
    }
    
}
